﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FileTest1.JavaFileOperator
{
    class JavaClass
    {
        public string id;
        public String accessModifier;
  
        public String className;
      
        public List<JavaParameter> parameterList;
        public string description;
        public List<JavaCodeLine> codes;
        public JavaClass(string id,
            string accessModifier,
            string methodName
           )
        {
            this.id = id;
            this.accessModifier = accessModifier;
           
            this.className = methodName;
           
            JavaCodeLine classBegin = new JavaCodeLine(CodeType.ClassBegin);
            classBegin.code = this.accessModifier + " class " + this.className + "{";
         
            JavaCodeLine classEnd = new JavaCodeLine(CodeType.ClassEnd);
            classEnd.code = "}";

            this.codes = new List<JavaCodeLine>();
            codes.Add(classBegin);
            codes.Add( new AttributeNote());
            codes.Add(new MethodNote());
            codes.Add(classEnd);
                
        }

        public void AddMethod(JavaMethod method)
        {
            foreach (JavaCodeLine line in method.codes)
            {
                line.code = "\t" + line.code;
            }
            for (int i = 0; i < this.codes.Count;i++ )
            {
                JavaCodeLine line = this.codes[i];
                if (line.type.Equals(CodeType.MethodNote))
                {
                    this.codes.InsertRange(i + 1, method.codes);
                }
            }
            
        }


    }
}
